/**
 * 
 */
package com.thinkgsp.sys.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 用户与角色关联类，此类用于在保存用户的角色时，作为参数使用
 * @author evan
 *
 */
public class SysUserRole extends SysModel implements Serializable {

	private static final long serialVersionUID = -8790450187097354461L;

	private Integer id;
	private Integer userId;
	private Integer roleId;
	
	/**
	 * id
	 * @return
	 */
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 用户ID
	 * @return
	 */
	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	/**
	 * 角色ID
	 * @return
	 */
	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#toString()
	 */
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("id",this.id)
		  .append("userId",this.userId)
		  .append("roleId",this.roleId);
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof SysUserRole)) {
			return false;
		}
		final SysUserRole ur = (SysUserRole)o;
		if(id != null) {
			return roleId.equals(ur.getId());
		} else {
			return (userId.equals(ur.getUserId()) && roleId.equals(ur.getRoleId()));
		}
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#hashCode()
	 */
	@Override
	public int hashCode() {
		return (this.id != null ? this.id.hashCode() : 0);
	}

}
